import requests

if __name__ == '__main__':
    key='玩偶姐姐'#input('请输入想要的：')
    url = 'https://www.hxc-api.com/videos/getList'
    payload = {"page":1,"length":12,"type":1,"searchText":key,"orderText":[{"dir":"desc","column":"addTimeStamp"}]}

    r = requests.post(url, data=payload)
    print(r.json()['data']['list'])
    videos=r.json()['data']['list']
    tempVideos=[]
    # 获取视频的id
    for video in videos:
        temp={
            'img':video['coverImgUrl'],
            'name':video['name'],
            'id':video['id'],
            'date':video['addTime'],
            'tags':video['tags']
        }
        tempVideos.append(temp)
    print(tempVideos)
    #登陆
    url2 = 'https://www.hxc-api.com/login/userLogin'
    payload2 = {"user_login": "1729051657@qq.com", "user_pass": "qwerty"}
    r2 = requests.post(url2, data=payload2)
    token=r2.json()['data']['token']

    # 获取视频的详细信息
    url1="https://www.hxc-api.com/videos/getPreUrl"
    payload1 = {"videoId": tempVideos[0]['id']}
    headers = {
        'auth': token
    }
    r1 = requests.post(url1, data=payload1, headers=headers)
    print(r1.json())

